<?php defined('SYSPATH') or die('No direct script access.');

class Controller_Base_FrontEnd extends Controller {
	
	public function  __construct(Request $request, Response $response) {
		parent::__construct($request, $response);
		
		$this->view = Smarty_View::factory('base/html.tpl');
        
                $this->view->js = array(
                    "jquery-1.8.2.min"=> array(
                            "type"=>"text/javascript",
                            "src"=>DOC_ROOT."modules/dec/static/jquery-ui-1.9.1.custom/js/jquery-1.8.2.js",
                            ),
                    "jquery-ui"=> array(
                            "type"=>"text/javascript",
                            "src"=>DOC_ROOT."modules/dec/static/jquery-ui-1.9.1.custom/js/jquery-ui-1.9.1.custom.min.js",
                            ),
                    "jquery-ui-datepicker-pt-BR"=> array(
                            "type"=>"text/javascript",
                            "src"=>DOC_ROOT."modules/dec/static/jscript/jquery.ui.datepicker-pt-BR.js",
                            ),
                    "general"=> array(
                            "type"=>"text/javascript",
                            "src"=>DOC_ROOT."modules/dec/static/jscript/general.js",
                            ),
                );
                $this->view->css = array(
                    "jquery-ui"=> array(
                            "rel"=>"stylesheet",
                            "href"=>DOC_ROOT."modules/dec/static/jquery-ui-1.9.1.custom/css/ui-lightness/jquery-ui-1.9.1.custom.min.css",
                            "type"=>"text/css",
                            "media"=>"screen",
                            "charset"=>"utf-8",
                    ),
                    "general" => array(
                        "rel" => "stylesheet",
                        "href"=>DOC_ROOT."modules/dec/static/css/general.css",
                        "type" => "text/css",
                        "media" => "screen",
                        "charset" => "utf-8",
                    ),
                    "frontend" => array(
                        "rel" => "stylesheet",
                        "href"=>DOC_ROOT."modules/dec/static/css/frontend.css",
                        "type" => "text/css",
                        "media" => "screen",
                        "charset" => "utf-8",
                    ),
                );
                $this->view->meta = array();
                $this->view->meta[] = array("http-equiv" => "Content-Type", "content" => "text/html;charset=UTF-8");
        
		$this->view->body = Smarty_View::factory('base/body_frontend.tpl');
		if(isset(Kohana::$config->load('dec')->google_key) && !empty (Kohana::$config->load('dec')->google_key)) {
			$this->view->body->google_key = Kohana::$config->load('dec')->google_key;
		}

		$this->view->title = Kohana::$config->load('dec')->sys_name;
		$this->view->body->top = Smarty_View::factory('top.tpl');
		$this->view->body->login = Decauth::frontend();
		$this->view->body->content = "Default Content";
		$this->view->body->footer = Arr::get(Kohana::modules(), "i18nUrl") ? (Views::Language(($redirect = substr(Request::current()->uri(),6))=="home/index"?'/':$redirect)) : "Default Footer";
		if (Kohana::$profiling) {
			$this->view->body->profile = View::factory('profiler/stats');
			$this->view->css["profile"] = array(
                            "rel" => "stylesheet",
                            "href"=>DOC_ROOT."modules/dec/static/css/profile.css",
                            "type" => "text/css",
                            "media" => "screen",
                            "charset" => "utf-8",
                        );
		}
	}
	
} // End Frontend